<template>
	<div class="conMain">
		<el-card class="box-card">
			<div slot="header" class="clearfix">
				<div class="container">
					<el-form :inline="true" size="small" label-width="120px">
						<el-row>
							<el-col :span="24">
								<el-form-item label="订单状态：">
									<el-radio-group v-model="params.s_status" type="button" @change="getList(1)">
										<el-radio-button label="">全部 </el-radio-button>
										<el-radio-button label="1">待同步</el-radio-button>
										<el-radio-button label="2">进行中</el-radio-button>
										<el-radio-button label="3">已成功</el-radio-button>
										<el-radio-button label="-1">失败</el-radio-button>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="回传状态：">
									<el-radio-group v-model="params.s_status_sync" type="button" @change="getList(1)">
										<el-radio-button label="">全部 </el-radio-button>
										<el-radio-button label="1">待同步</el-radio-button>
										<el-radio-button label="2">进行中</el-radio-button>
										<el-radio-button label="3">已成功</el-radio-button>
										<el-radio-button label="-1">失败</el-radio-button>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="创建时间：">
									<el-radio-group v-model="params.date" type="button" class="mr20" size="small"
										@change="selectChange()">
										<el-radio-button v-for="(item,i) in fromList.fromTxt" :key="i"
											:label="item.val">{{ item.text }}</el-radio-button>
									</el-radio-group>
									<el-date-picker v-model="params.s_createtime" value-format="yyyy-MM-dd"
										format="yyyy-MM-dd" size="small" type="daterange" placement="bottom-end"
										placeholder="自定义时间" style="width: 250px;" @change="onchangeTime" />
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="更新时间：">
									<el-radio-group v-model="params.date2" type="button" class="mr20" size="small"
										@change="selectChange2()">
										<el-radio-button v-for="(item,i) in fromList.fromTxt" :key="i"
											:label="item.val">{{ item.text }}</el-radio-button>
									</el-radio-group>
									<el-date-picker v-model="params.s_uptime" value-format="yyyy-MM-dd"
										format="yyyy-MM-dd" size="small" type="daterange" placement="bottom-end"
										placeholder="自定义时间" style="width: 250px;" @change="onchangeTime2" />
								</el-form-item>
							</el-col>
						</el-row>

						<div v-show="box">
							<el-form-item label="订单ID">
								<el-input clearable v-model="params.s_id" placeholder="请输入订单ID" />
							</el-form-item>
							<el-form-item label="订单编号">
								<el-input clearable v-model="params.s_sn" placeholder="请输入订单编号" />
							</el-form-item>
						<el-form-item label="结算类型">
							<el-select v-model="params['s_goods*jslx']" clearable placeholder="请选择">
								<el-option v-for="(item,index) in jslxlist" :label="item.txt" :value="item.val" />
							</el-select>
						</el-form-item>
							<el-form-item label="所属渠道" v-if="role != 3 && role != 5">
								<el-select filterable clearable v-model="params.s_pass_id" placeholder="请选择"
									@change="changepass">
									<el-option :label="item.name" :value="item.id" v-for="(item,index) in passlist" />
								</el-select>
							</el-form-item>
							<el-form-item label="商品名称">
								<el-select clearable v-model="params.s_goods_id" placeholder="请先选择渠道">
									<el-option :label="item.name" :value="item.id" v-for="(item,index) in goodslist" />
								</el-select>
							</el-form-item>
							<el-form-item label="订单来源">
								<el-select clearable v-model="params.s_from" placeholder="请选择订单来源">
									<el-option :label="item.txt" :value="item.val" v-for="(item,index) in fromst" />
								</el-select>
							</el-form-item>
							<el-form-item label="收货电话">
								<el-input clearable v-model="params.s_post_mobile" placeholder="请输入收货电话" />
							</el-form-item>
							<el-form-item label="订购号码">
								<el-input clearable v-model="params.s_phone" placeholder="请输入订购号码" />
							</el-form-item>
							<el-form-item label="姓名">
								<el-input clearable v-model="params.s_name" placeholder="请输入姓名" />
							</el-form-item>
							<el-form-item label="第三方单号" v-if="role != 3  && role != 5">
								<el-input clearable v-model="params.s_orderno" placeholder="请输入第三方单号" />
							</el-form-item>
							<el-form-item label="卡状态">
								<el-select clearable v-model="params.s_u_status" placeholder="请选择卡状态">
									<el-option :label="item.txt" :value="item.val" v-for="(item,index) in ustatusst" />
								</el-select>
							</el-form-item>

							<el-form-item label="代理姓名">
								<el-input clearable v-model="params['s_agent*name']" placeholder="请输入代理姓名" />
							</el-form-item>
							<el-form-item label=" ">
								<el-button type="primary" size="small" class="searchBtn" @click="handleSearch"
									icon='el-icon-search'>搜索</el-button>
								<el-button type="info" @click="handleRet" plain>重置</el-button>
							</el-form-item>
						</div>
					</el-form>
					<div style="text-align: right;">
						<el-button v-if="role != 3  && role != 5" v-has="'order/finish'" type="primary" size="small" class="ml10"
							@click="sjpp" plain><i class="el-icon-circle-check" /> 数据匹配</el-button>
						<el-button v-if="role != 3  && role != 5" v-has="'order/finish'" type="warning" size="small" class="ml10"
							@click="finish" plain><i class="el-icon-circle-check" /> 导入完成</el-button>
						<el-button v-has="'order/export'" type="primary" size="small" class="ml10" @click="down"
							plain><i class="el-icon-download" /> 批量导出</el-button>
						<!-- <el-button v-has="'order/importorder'"  type="info" size="small" class="ml10" @click="importorder" plain><i class="el-icon-upload" /> 导入订单</el-button> -->
						<el-button icon="el-icon-search" type="info" plain size="small" @click="changebox"></el-button>
					</div>
				</div>

			</div>
			<el-table v-loading="loading" :data="list" style="width: 100%" :empty-text='emtypetxt'>
				<el-table-column type="expand">
					<template slot-scope="props">
						<el-row>
							<el-col :span="6">
								订单ID：{{props.row.id}}
							</el-col>
							<el-col :span="6">
								订单编号：{{props.row.sn}}
							</el-col>
							<el-col :span="6" v-if="role != 3  && role != 5">
								所属渠道：{{props.row.passage.name}}
							</el-col>
							<el-col :span="6">
								商品名称：{{props.row.goods.name}}
							</el-col>

						</el-row>
						<el-row style="margin-top: 10px;">
							<el-col :span="6">
								身份证号：{{props.row.card}}
							</el-col>
							<el-col :span="6">
								收货地区：{{props.row.post_province}}-{{props.row.post_city}}-{{props.row.post_district}}
							</el-col>
							<el-col :span="6">
								详细地址：{{props.row.post_addr}}
							</el-col>
							<el-col :span="6">
								卡状态：{{props.row.u_status_txt}}
							</el-col>
						</el-row>
						<el-row style="margin-top: 10px;">
							<el-col :span="6">
								订单来源：{{props.row.from_text}}
							</el-col>
							<el-col :span="6">
								物流公司：{{props.row.logistics_company}}
							</el-col>
							<el-col :span="6">
								物流单号：{{props.row.logistics_no}}
							</el-col>
							<el-col :span="6">
								代理信息：{{props.row.agent_id}}-{{props.row.agent.name}}
							</el-col>
						</el-row>
						<el-row style="margin-top: 10px;" v-if="props.row.fee_text[0]">
							<el-col :span="6">
								直接佣金：{{props.row.fee_text[0]}}
							</el-col>
							<el-col :span="6">
								上级佣金：{{props.row.fee_text[1]}}
							</el-col>
							<el-col :span="6">
								上上级佣金：{{props.row.fee_text[2]}}
							</el-col>

						</el-row>
						<el-row style="margin-top: 10px;">
							<el-col :span="6">
								失败原因：{{props.row.status_msg}}
							</el-col>
							<el-col :span="6">
								触点编码：{{props.row.channel}}
							</el-col>
							<el-col :span="6" v-if="role != 3  && role != 5">
								第三方单号：{{props.row.orderno}}
							</el-col>
						</el-row>
							<el-row style="margin-top: 10px;">
							<el-col :span="6">
								自动转单：
								<span v-if="props.row.zd === 2">是</span>
								<span v-else>否</span>
							</el-col>
							<el-col :span="6">
								转单来源：{{props.row.zdsn}}
							</el-col>
						</el-row>
					</template>
				</el-table-column>
				<el-table-column prop="sn" label="订单编号" align="center" width="240" :show-overflow-tooltip="true" />
				<el-table-column prop="passage.name" label="所属渠道" align="center" width="150"
					:show-overflow-tooltip="true" v-if="role != 3  && role != 5" />
				<el-table-column prop="goods.name" label="商品名称" align="center" width="120"
					:show-overflow-tooltip="true" />
				<el-table-column prop="goods.jslx" label="结算类型" align="center">
					<template slot-scope="scope">
						<span v-if="scope.row.goods.jslx == 1">日结</span>
						<span v-else-if="scope.row.goods.jslx == 2">月结</span>
					</template>
				</el-table-column>
				<el-table-column prop="phone" label="订购号码" align="center" width="110" />
				<el-table-column label="归属地" align="center" width="100" :show-overflow-tooltip="true">
					<template slot-scope="scope">
						{{scope.row.phone_province}}-{{scope.row.phone_city}}
					</template>
				</el-table-column>
				<el-table-column prop="name" label="姓名" align="center" width="100" :show-overflow-tooltip="true" />

				<el-table-column label="收货地区" align="center" width="120" :show-overflow-tooltip="true">
					<template slot-scope="scope">
						{{scope.row.post_province}}-{{scope.row.post_city}}-{{scope.row.post_district}}
					</template>
				</el-table-column>
				<el-table-column prop="post_mobile" label="收货电话" align="center" width="110" />
				<el-table-column prop="agent.name" label="代理姓名" align="center" width="110"
					:show-overflow-tooltip="true" />
				<el-table-column prop="sc_money" label="首充金额" align="center" width="80" :show-overflow-tooltip="true" />
				<el-table-column label="状态" align="center" width="100">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.status === 1" type="info" size="mini" disable-transitions>待同步</el-tag>
						<el-tag v-else-if="scope.row.status === 2" type="primary" size="mini"
							disable-transitions>进行中</el-tag>
						<el-tag v-else-if="scope.row.status === 3" type="success" size="mini"
							disable-transitions>已成功</el-tag>
						<el-tag v-else-if="scope.row.status === -1" type="danger" size="mini"
							disable-transitions>失败</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="回传状态" align="center" width="100">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.status_sync === 1" type="info" size="mini" disable-transitions>待同步</el-tag>
						<el-tag v-else-if="scope.row.status_sync === 2" type="primary" size="mini"
							disable-transitions>进行中</el-tag>
						<el-tag v-else-if="scope.row.status_sync === 3" type="success" size="mini"
							disable-transitions>已成功</el-tag>
						<el-tag v-else-if="scope.row.status_sync === -1" type="danger" size="mini"
							disable-transitions>失败</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="uptime" label="更新时间" align="center" width="160" />
				<el-table-column prop="createtime" label="创建时间" align="center" width="160" />
				<el-table-column  fixed="right" label="操作" align="center" width="120"  v-if="role != 3 && role != 5">
					<template slot-scope="scope">
						<el-link v-if="scope.row.status==2 " v-has="'order/succ'" :underline="false" type="primary"
							title='成功' @click="succ(scope.row.id)" class='ml10'>成功</el-link>
						<el-link v-if="scope.row.status==1 || scope.row.status==2 " v-has="'order/seterror'"
							:underline="false" type="danger" title='失败' @click="seterror(scope.row.id)"
							class='ml10'>失败</el-link>
						<el-link v-if="scope.row.status==-1" :underline="false" type="info" title='退回进行中'
							@click="settotwo(scope.row.id)" class='ml10'>进行中</el-link>

					</template>
				</el-table-column>
				<el-table-column  fixed="right" label="操作" align="center" width="0"  v-else>
				</el-table-column>
			</el-table>
			<div class="pagination">
				<el-pagination :current-page="params.page" :page-sizes="[10, 20, 50, 100]" :page-size="params.pagesize"
					layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
					@current-change="handleCurrentChange" />
			</div>
		</el-card>
		<el-dialog title="数据匹配" :visible.sync="sjppVisible" :close-on-click-modal="false" center width="40%">
			<el-form :model="sub" label-width="110px">
				<el-form-item label="匹配类型：">
					<el-radio-group v-model="sub.s_type" type="button">
						<el-radio-button label="1">订购号码</el-radio-button>
						<el-radio-button label="2">收货号码</el-radio-button>
						<el-radio-button label="3">订单编号</el-radio-button>
						<el-radio-button label="4">第三方单号</el-radio-button>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="上传文件" style="margin-top: 30px;">
					<el-upload action="" :limit="1" :on-exceed="handleExceed" :on-remove="handleRemove" accept="*"
						:before-upload="beforeUpload" :file-list="fileList" :http-request="uploadExcel">
						<el-button size="small" type="primary">点击上传</el-button>
						<div slot="tip" class="el-upload__tip" style="color:red">只能上传EXCEL文件，第一行标题为匹配类型，第一列第二行开始为所匹配电话号码</div>
					</el-upload>

				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="sjppVisible = false">取 消</el-button>
				<el-button type="primary" @click="subSjpp">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="导入完成订单" :visible.sync="dialogVisible" :close-on-click-modal="false" center width="40%">
			<el-form :model="sub" label-width="110px">
				<el-form-item label="所属渠道" style="margin-top: 30px;">
					<el-select filterable clearable v-model="sub.pass_id" placeholder="请选择">
						<el-option :label="item.name" :value="item.id" v-for="(item,index) in passlist" />
					</el-select>
				</el-form-item>
				<el-form-item label="上传文件" style="margin-top: 30px;">
					<el-upload action="" :limit="1" :on-exceed="handleExceed" :on-remove="handleRemove" accept="*"
						:before-upload="beforeUpload" :file-list="fileList" :http-request="uploadExcel">
						<el-button size="small" type="primary">点击上传</el-button>
						<div slot="tip" class="el-upload__tip">只能上传EXCEL文件，且不超过3M，每次最多100条数据<span class="ml10"
								@click="seeMb">【查看模板】</span></div>
					</el-upload>

				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="subForm">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="导入订单" :visible.sync="dialogVisiblep" :close-on-click-modal="false" center width="40%">
			<el-form :model="sub" label-width="110px">
				<el-form-item label="上传文件" style="margin-top: 30px;">
					<el-upload action="" :limit="1" :on-exceed="handleExceed" :on-remove="handleRemove" accept="*"
						:before-upload="beforeUpload" :file-list="fileList" :http-request="uploadExcel">
						<el-button size="small" type="primary">点击上传</el-button>
						<div slot="tip" class="el-upload__tip">只能上传EXCEL文件，且不超过3M，每次最多100条数据<span class="ml10"
								@click="seeMbp">【查看模板】</span></div>
					</el-upload>

				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisiblep = false">取 消</el-button>
				<el-button type="primary" @click="subFormp">确定</el-button>
			</div>
		</el-dialog>


	</div>
</template>

<script>
	import {
		order_index,
		order_export,
		order_export_csv,
		order_finish,
		order_sjpp,
		order_succ,
		order_seterror,
		order_settotwo,
		order_importOrder
	} from '@/api/order'
	import {
		passage_list,
		goods_getCgoods
	} from '@/api/passage'
	import {
		general_upload
	} from '@/api/attach'

	import {
		fromList
	} from '@/libs/select.js'

	export default {
		data() {
			return {
				dialogVisible: false,
				sjppVisible: false,
				box: true,
				total: 0,
				role: 0,
				loading: true,
				emtypetxt: '',
				list: [],
				jslxlist: [{
					val: '1',
					txt: '日结'
				}, {
					val: '2',
					txt: '月结'
				}],
				passlist: [], //渠道列表
				goodslist: [], //商品列表
				fromList: fromList,
				params: {
					s_status: '',
					s_status_sync: '',
					date: 'all',
					date2: 'all',
					s_createtime: [],
					s_uptime: [],
					s_id: '',
					s_sn: '',
					s_pass_id: '',
					s_goods_id: '',
					s_phone: '',
					s_name: '',
					s_u_status: '',
					s_orderno: '',
					s_from: '',
					's_agent*name': '',
					's_goods*jslx': '',
					ss_createtime: 'BETWEEN',
					ss_uptime: 'BETWEEN',
					page: 1,
					pagesize: 10,
				},
				sub: {
					pass_id: '',
					s_goods_id: '',
					s_type: '',
					file: '',
				},
				fileList: [], //上传的文件
				fromst: [{
					val: '1',
					txt: '落地页'
				}, {
					val: '2',
					txt: 'API接口'
				}, {
					val: '3',
					txt: '导入'
				}],
				ustatusst: [{
						val: '1',
						txt: '激活'
					},
					{
						val: '2',
						txt: '退单'
					},
					{
						val: '3',
						txt: '转套餐'
					},
					{
						val: '4',
						txt: '销户'
					},
					{
						val: '6',
						txt: '已首充'
					},
					{
						val: '10',
						txt: '开户完成'
					},
					{
						val: '11',
						txt: '发货'
					},
					{
						val: '-2',
						txt: '异常'
					},
					{
						val: '-1',
						txt: '无'
					},
				],
				dialogVisiblep: false,
			}
		},
		created() {
			passage_list().then(res => {
				this.passlist = res.data
			})
			this.getList()
		},
		methods: {
			getList(page) {
				this.params.page = page ? page : this.params.page;
				this.emtypetxt = '加载中...';
				this.loading = true;
				order_index(this.params).then(res => {
					this.list = res.data.list
					this.total = res.data.total
					this.role = res.data.role
					this.loading = false
					if (this.list.length == 0) {
						this.emtypetxt = '暂无数据'
					}
				})
			},
			// 时间筛选
			selectChange(tab) {
				this.params.s_createtime = [];
				this.getList(1);
			},
			// 时间筛选
			selectChange2(tab) {
				this.params.s_uptime = [];
				this.getList(1);
			},
			onchangeTime(e) {
				this.params.date = 'all';
				this.params.s_createtime = e;
				this.getList(1);
			},
			onchangeTime2(e) {
				this.params.date2 = 'all';
				this.params.s_uptime = e;
				this.getList(1);
			},
			handleSearch() {
				this.getList(1)
			},
			//分页
			handleSizeChange(val) {
				this.params.pagesize = val
				this.getList(1)
			},
			handleCurrentChange(val) {
				this.params.page = val
				this.getList()
			},
			changebox() {
				this.box = !this.box;
			},
			handleRet() {
				this.params = {
					s_status: '',
					s_status_sync: '',
					date: 'all',
					date2: 'all',
					s_createtime: [],
					s_uptime: [],
					s_id: '',
					s_sn: '',
					s_pass_id: '',
					s_goods_id: '',
					s_phone: '',
					s_name: '',
					s_u_status: '',
					s_orderno: '',
					s_from: '',
					's_agent*name': '',
					ss_createtime: 'BETWEEN',
					ss_uptime: 'BETWEEN',
					page: 1,
					pagesize: 10,
				}
				this.goodslist = []
				this.getList()
			},

			//上传文件开始
			handleExceed(files, fileList) {
				this.$message.warning(`每次只能上传1个文件`);
			},
			handleRemove(file, fileList) {
				this.sub.file = ''
			},
			beforeUpload(file) {
				if (file.size > 1024 * 1024 * 5) {
					this.$message.warning('文件不能大于5M')
					return false;
				}
				const isText = file.type === 'application/vnd.ms-excel';
				const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
				if (!isText && !isTextComputer) {
					this.$message.warning('请上传excel格式文件！');
				};
				return (isText || isTextComputer);
			},
			finish() {
				this.dialogVisible = true
				this.sub.pass_id = ''
				this.sub.s_goods_id = ''
				this.sub.file = ''
				this.sub.s_type = ''
				this.fileList = []
			},
			sjpp() {
				this.sjppVisible = true
				this.sub.pass_id = ''
				this.sub.s_goods_id = ''
				this.sub.file = ''
				this.sub.s_type = ''
				this.fileList = []
			},
			subForm() {
				if (!this.sub.pass_id) {
					return this.$message.warning('请选择渠道');
				}
				if (!this.sub.file) {
					return this.$message.warning('请上传文件');
				}
				const loading = this.$loading({
					lock: true,
					text: '处理中...',
					spinner: 'el-icon-loading',
					background: 'rgba(20, 20, 20, 0.7)'
				});
				order_finish(this.sub).then(res => {
					if (res.code == 9) {
						this.$message.error(res.msg);
						loading.close();
					} else {
						this.$message.success(res.msg);
						this.getList()
						this.dialogVisible = false
						loading.close();
					}
				})
			},
			subSjpp() {
				if (!this.sub.s_type) {
					return this.$message.warning('请选择匹配类型');
				}
				if (!this.sub.file) {
					return this.$message.warning('请上传文件');
				}
				
				const loading = this.$loading({
					lock: true,
					text: '处理中...',
					spinner: 'el-icon-loading',
					background: 'rgba(20, 20, 20, 0.7)'
				});
				order_sjpp(this.sub).then(res => {
					if (res.code == 9) {
						this.$message.error(res.msg);
						loading.close();
					} else {
						window.location.href = res.data.filename
						loading.close()
					}
				})
			},
			uploadExcel(item) {
				const sub = new FormData();
				sub.append('file', item.file);
				general_upload(sub).then(res => {
					this.$message.success('上传成功');
					this.sub.file = res.data.fullurl
				})
			},
			seeMb() {
				window.open('/uploads/demo_hk.jpg');
			},
			//上传文件结束

			//上传文件开始2
			importorder() {
				this.dialogVisiblep = true
				this.sub.file = ''
				this.fileList = []
			},
			subFormp() {
				if (!this.sub.file) {
					return this.$message.warning('请上传文件');
				}
				const loading = this.$loading({
					lock: true,
					text: '处理中...',
					spinner: 'el-icon-loading',
					background: 'rgba(20, 20, 20, 0.7)'
				});
				order_importOrder(this.sub).then(res => {
					if (res.code == 9) {
						this.$message.error(res.msg);
						loading.close();
					} else {
						this.$message.success(res.msg);
						this.getList()
						this.dialogVisiblep = false
						loading.close();
					}
				})
			},
			seeMbp() {
				window.open('/uploads/demo_import.jpg');
			},
			//上传文件结束2



			succ(id) {
				let _this = this;
				_this.$modalSure('您确定要成功该订单嘛？将会给代理结算').then(() => {
					order_succ({
						id: id
					}).then(res => {
						_this.$message.success(res.msg)
						_this.getList()
					})
				})
			},
			seterror(id) {
				let _this = this;
				_this.$prompt('请输入失败原因', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					inputPattern: /\S/,
					inputErrorMessage: '请输入失败原因'
				}).then(({
					value
				}) => {

					order_seterror({
						status_msg: value,
						id: id
					}).then(res => {
						_this.$message.success(res.msg)
						_this.getList()
					})

				}).catch(() => {
					_this.$message({
						type: 'info',
						message: '取消输入'
					});
				});

				// _this.$modalSure('您确定要设置该【订单失败】嘛？').then(() => {
				//   order_seterror({id:id}).then(res => {
				//     _this.$message.success(res.msg)
				//     _this.getList()
				//   })
				// })
			},
			settotwo(id) {
				let _this = this;
				_this.$modalSure('您确定要设置该失败订单转【进行中】嘛？').then(() => {
					order_settotwo({
						id: id
					}).then(res => {
						_this.$message.success(res.msg)
						_this.getList()
					})
				})
			},
			changepass(e) {
				this.params.s_goods_id = ''
				goods_getCgoods({
					pass_id: e
				}).then(res => {
					this.goodslist = res.data
				})

			},

			down() {
				const loading = this.$loading({
					lock: true,
					text: '正在导出...',
					spinner: 'el-icon-loading',
					background: 'rgba(20, 20, 20, 0.7)'
				});
				// order_export(this.params).then(res => {
				// 	const {
				// 		export_json_to_excel
				// 	} = require('../../assets/js/Export2Excel');
				// 	const tHeader = res.data.header;
				// 	const filterVal = res.data.filter;
				// 	const list = res.data.list;
				// 	const data = this.formatJson(filterVal, list);
				// 	export_json_to_excel(tHeader, data, res.data.ename);
				// 	loading.close();
				// })
				order_export_csv(this.params).then(res => {
					window.location.href = res.data.filename
					loading.close()
				})
			},
			formatJson(filterVal, jsonData) {
				return jsonData.map(v => filterVal.map(j => v[j]))
			},
		},
	}
</script>

<style>
	.el-upload__tip {
		color: #afafaf;
	}
</style>